import requests


class EmpApi(object):
    def __init__(self):
        self.url = 'http://ihrm-test.itheima.net/api/sys/user'

    def add_emp(self, emp_info, authorization):
        """
        :param emp_info: POST 请求体，员工信息
        :param authorization: token
        :return:
        """
        return requests.post(self.url, json=emp_info, headers=authorization)

    # 查询员工
    def query_emp(self, emp_id, authorization):
        return requests.get(self.url + '/' + emp_id, headers=authorization)

    # 修改员工信息
    def update_emp(self, emp_id, emp_update_info, auth_header):
        return requests.put(self.url + '/' + emp_id, json=emp_update_info,  headers=auth_header)

    # 删除员工信息
    def delete_emp(self, emp_id, auth_header):
        return requests.delete(self.url + '/' + emp_id, headers=auth_header)
